import multiprocessing
import time,os
from tkinter.font import names


def sing(num,name):
    print("唱歌的进程编号:", os.getpid())
    for i in range(num):
        print(name,end='')
        print("唱歌...")
        time.sleep(0.5)
def dance(num,name):
    print("跳舞的进程编号:",os.getpid())
    print("跳舞的父进程编号：",os.getppid())
    for i in range(num):
        print(name,end='')
        print("跳舞...")
        time.sleep(0.5)

if __name__=='__main__':
    #使用进程类创建进程对象
    #target：指定进程执行的函数名
    #args:使用元组方式给指定任务传参
    #kwargs:使用字典方式给指定任务传参
    print("主进程ID：",os.getpid())
    sing_process = multiprocessing.Process(target=sing,args=(3,"小李"))
    dance_process = multiprocessing.Process(target=dance,kwargs={'num':3,'name':'小张'})
    sing_process.start()
    dance_process.start()



